<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>게시판 글 쓰기 결과</title>
</head>
<body>
<h1>게시판 글 쓰기 결과</h1>
<%
	request.setCharacterEncoding("UTF-8");
	String DRV = "org.mariadb.jdbc.Driver";
	String URL = "jdbc:mariadb://localhost:3306/jwj8508?user=jwj8508&password=123456";
	String sql = "insert into boardv4(title, uid, contents) values(?, ?, ?)";
	
	String title = null;	
	String uid = null;
	String contents = null;
	
	title = request.getParameter("title");
	uid = request.getParameter("uid");
	contents = request.getParameter("contents");
	contents = contents.replace("\r\n", "<br />");
	
	Connection conn = null;
	PreparedStatement pstmt = null;
	
	try {
		Class.forName(DRV);
		conn = DriverManager.getConnection(URL);
		pstmt = conn.prepareStatement(sql);
		
		pstmt.setString(1, title);
		pstmt.setString(2, uid);
		pstmt.setString(3, contents);
		pstmt.executeUpdate();
		
		out.print("<h3 style='color: red;'>글 등록 완료</h3>");
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if (pstmt!=null)try{pstmt.close();}catch(Exception e){}
		if (conn!=null)try{conn.close();}catch(Exception e){}
	}
%>
<%
	response.sendRedirect("list.jsp");
%>
</body>
</html>